<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="炼厂ID">
              <a-input placeholder="请输入炼厂ID" v-model="queryParam.refineryId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="炼厂地址">
              <a-input placeholder="请输入炼厂地址" v-model="queryParam.refineryAddress"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="车牌号">
              <a-input placeholder="请输入车牌号" v-model="queryParam.carNum"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="状态">
              <a-select ref="select" placeholder='请选择订单状态' v-model="queryParam.status">
                <a-select-option v-for="(statusText, statusValue) in statusOptions" :key="statusValue"
                  :value="statusValue">
                  {{ statusText }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd1" type="primary" icon="plus">新增</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
          style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table :scroll="{ x: 2300}" ref="table" size="middle" bordered rowKey="id" :columns="columns"
        class="ant-table-striped" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
        :rowClassName="(record, index) => (record.chaoShiFlag === 1 ? 'table-striped' : null)"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange">
        <span slot="status" slot-scope="text, record">
          {{record.status==0?'匹配中':record.status==1?'已接单':record.status==2?'赶往炼厂':record.status==3?'已到达炼厂':record.status==4?'验罐已提交':record.status==5?'进出场照片已提交':record.status==6?'磅单照片已提交':
        record.status==7?'物料照片已提交':record.status==8?'铅封照片已提交':record.status==9?'油样瓶照片已提交':record.status==10?'安全交付袋已提交':record.status==11?'订单已转单':record.status==12?"用户已确认":""}}
        </span>

        <span slot="transferStatus" slot-scope="text, record">
          {{record.transferStatus==0?'等待接单':record.transferStatus==1?'未接单，再次转单':"已接单"}}
        </span>
        <span slot="orderType" slot-scope="text, record">
          {{record.orderType==1?'派单任务':record.orderType==2?'抢单任务':"转单任务"}}
        </span>

        <span slot="refineryName" slot-scope="text, record">
          {{record.refineryId+"-"+record.refineryName+"-"+record.refineryAddress+"-"+(record.sealUserFlag==1?'有封车人员':'无封车人员')}}
        </span>


        <span slot="driverName" slot-scope="text, record">
          {{record.driverName+"-"+record.driverPhone+"-"+record.carNum}}
        </span>

        <span slot="userName" slot-scope="text, record">
          {{record.userId+"-"+record.userName+"-"+record.userPhone}}
        </span>

        <span slot="incomingUserName" slot-scope="text, record">
          <div v-if="record.incomingUserPhone && record.incomingUserName">
            {{record.incomingUserName+"-"+record.incomingUserPhone}}
          </div>
        </span>

        <span slot="transferUserName" slot-scope="text, record">
          <div v-if="record.transferUserName">
            {{record.transferUserName+"-"+record.transferUserPhone+"-"+(record.transferTime?record.transferTime:'')}}
          </div>
        </span>

        <span slot="commission" slot-scope="text, record">
          {{record.commission+'+'+record.additionalPrice}}
        </span>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">调度</a>

          <a-divider type="vertical" />
          <!-- <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" /> -->
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <ysySealCarOrder-modal ref="modalForm" @ok="modalFormOk"></ysySealCarOrder-modal>
    <AddSealCarOrderModal ref="modalForm1" @ok="modalFormOk1"></AddSealCarOrderModal>
  </a-card>
</template>

<script>
  import YsySealCarOrderModal from './modules/YsySealCarOrderModal'
  import AddSealCarOrderModal from './modules/AddSealCarOrderModal'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'

  export default {
    name: "YsySealCarOrderList",
    mixins: [JeecgListMixin],
    components: {
      YsySealCarOrderModal,
      AddSealCarOrderModal
    },
    data() {
      return {
        statusOptions: {
          "0": "匹配中",
          "1": "已接单",
          "2": "赶往炼厂",
          "3": "已到达炼厂",
          "4": "验罐已提交",
          "5": "进出场照片已提交",
          "6": "磅单照片已提交",
          "7": "物料照片已提交",
          "8": "铅封照片已提交",
          "9": "油样瓶照片已提交",
          "10": "安全交付袋已提交",
          "11": "订单已转单",
          "12": "用户已确认"
        },
        description: '封车订单表管理页面',
        // 表头
        columns: [{
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender: function(t, r, index) {
              return parseInt(index) + 1;
            },
            fixed: 'left'
          },
          {
            title: '订单类型',
            align: "center",
            dataIndex: 'orderType',
            scopedSlots: {
              customRender: 'orderType',
            },
            fixed: 'left',
            width: 200
          },
          // {
          //   title: '转单状态',
          //   align: "center",
          //   dataIndex: 'transferStatus',
          //   scopedSlots: {
          //     customRender: 'transferStatus'
          //   },
          //   fixed: 'left',
          //   width: 200
          // },
          {
            title: '下单时间',
            align: "center",
            dataIndex: 'createTime',

          },
          {
            title: '状态',
            align: "center",
            dataIndex: 'status',
            scopedSlots: {
              customRender: 'status'
            },
          },
          {
            title: '炼厂名称',
            align: "center",
            dataIndex: 'refineryName',
            scopedSlots: {
              customRender: 'refineryName'
            },
          },
          {
            title: '接单时间',
            align: "center",
            dataIndex: 'incomingTime'
          },
          {
            title: '司机信息',
            align: "center",
            dataIndex: 'driverName',
            scopedSlots: {
              customRender: 'driverName'
            },
          },
          {
            title: '佣金信息',
            align: "center",
            dataIndex: 'commission',
            scopedSlots: {
              customRender: 'commission'
            },
          },
          {
            title: '发布用户信息',
            align: "center",
            dataIndex: 'userName',
            scopedSlots: {
              customRender: 'userName'
            },
          },
          {
            title: '接单用户信息',
            align: "center",
            dataIndex: 'incomingUserName',
            scopedSlots: {
              customRender: 'incomingUserName'
            },
          },
          {
            title: '转单信息',
            align: "center",
            dataIndex: 'transferUserName',
            scopedSlots: {
              customRender: 'transferUserName'
            },
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {
              customRender: 'action'
            },
            fixed: 'right',
            width: 200
          }
        ],
        url: {
          list: "/app/ysySealCarOrder/list",
          delete: "/app/ysySealCarOrder/delete",
          deleteBatch: "/app/ysySealCarOrder/deleteBatch",
          exportXlsUrl: "app/ysySealCarOrder/exportXls",
          importExcelUrl: "app/ysySealCarOrder/importExcel",
        },
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      handleAdd1() {
        this.$refs.modalForm1.add()
      },
      modalFormOk1() {
        this.searchReset()
      }
    }
  }
</script>
<style scoped>
  .ant-table-striped :deep(.table-striped) td {
    background-color: #fff3b3;
  }

  @import '~@assets/less/common.less';
</style>